//
//  FMTable.h
//  面向对象的数据库操作
//
//  Created by appbanana on 2017/3/18.
//  Copyright © 2017年 appbanana. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMModelTool.h"

typedef NS_ENUM(NSUInteger, RelationType) {
    RelationTypeGreater,
    RelationTypeLess,
    RelationTypeEqual,
    RelationTypeGreaterEqual,
    RelationTypeLessEqual,
    RelationTypeNotEqual
};

typedef enum : NSUInteger {
    FMSqliteLogicTypeNot,
    FMSqliteLogicTypeAnd,
    FMSqliteLogicTypeOr,
} FMSqliteLogicType;


@interface FMTable : NSObject

//+ (BOOL)createTableWithModelClass:(Class)cls uid:(NSString *)uid;


+ (BOOL)saveOrUpdate:(id)model uid:(NSString *)uid;

//查询
+ (NSArray *)queryAllModels:(Class)cls uid:(NSString *)uid;

+ (NSArray *)queryModels:(Class)cls key:(NSString *)key relation:(RelationType)type value:(id)value uid:(NSString *)uid;

+ (NSArray *)queryModels:(Class)cls keys: (NSArray *)keys relations: (NSArray *)relations values: (NSArray *)values nao: (NSArray *)naos uid: (NSString *)uid;
//
+ (NSArray *)queryModels:(Class)cls sql:(NSString *)sqlStr uid:(NSString *)uid;

//删除所有模型
+ (BOOL)deleteAllModel:(Class)cls uid:(NSString *)uid;

//删除某个指定模型
+ (BOOL)deleteSomeModel:(id)model uid:(NSString *)uid;

//根据某个条件批量删除数据
// delete from stu where age = '10';
+ (BOOL)deleteModels:(Class)cls sql:(NSString *)sql uid:(NSString *)uid;

//根据指定的条件批量删除数据 这个比上面的灵活些
+ (BOOL)deleteModels:(Class)cls key:(NSString *)key relationType:(RelationType)type value:(id )value uid:(NSString *)uid;

+ (BOOL)deleteModel:(Class)cls keys: (NSArray *)keys relations: (NSArray *)relations values: (NSArray *)values nao: (NSArray *)naos uid: (NSString *)uid;


+ (BOOL)createTable:(Class)cls uid:(NSString *)uid;


+ (BOOL)isTableExists:(Class)cls uid:(NSString *)uid;

+ (BOOL)isTableRequireUpdate:(Class)cls uid:(NSString *)uid;

+ (BOOL)updateTable:(Class)cls uid:(NSString *)uid;

@end
